package com.wangzhenyu.learn.test.android_.activityViewModel

import android.app.Activity
import android.content.Intent
import androidx.lifecycle.ViewModel
import com.wangzhenyu.common.base.BaseApplication
import com.wangzhenyu.learn.test.android_.activity.SecondTestActivity
import com.wangzhenyu.learn.test.ThirdTestActivity
import com.wangzhenyu.learn.test.android_.activity.TestViewActivity


object TestSelect {
    //UI测试
    val list1 = listOf("自定义View", "Compose测试一")

    //自定义View
    fun firstZero(activity: Activity) {
        activity.startActivity(
            Intent(
                BaseApplication.myApplication, TestViewActivity::class.java
            )
        )
    }


    //日常测试
    val list2 = listOf("资源类测试", "fragment测试")

    //资源类测试
    fun secondZero(activity: Activity) {
        activity.startActivity(
            Intent(
                BaseApplication.myApplication,
                SecondTestActivity::class.java
            )
        )
    }

    fun secondOne(activity: Activity) {
        activity.startActivity(
            Intent(
                BaseApplication.myApplication,
                ThirdTestActivity::class.java
            )
        )
    }
}

class TestViewModel : ViewModel() {


    private val item1 = TestItem.TestParentItem(
        listOf(
            TestItem.TestChildItem(TestSelect.list1[0]), TestItem.TestChildItem(TestSelect.list1[1])
        ), "UI测试"
    )

    private val item2 = TestItem.TestParentItem(
        listOf(
            TestItem.TestChildItem(TestSelect.list2[0]), TestItem.TestChildItem(TestSelect.list2[1])
        ), "日常测试"
    )

    val testData: TestItem = TestItem(
        mutableListOf(
            item1, item2
        )
    )
}

data class TestItem(val parent: MutableList<TestItemType>) {

    data class TestParentItem(
        val child: List<TestItemType>,
        override val name: String = "测试"
    ) : TestItemType {

        var isExpand = false

        override fun getTestItemType(): TestItemEnum {
            return TestItemEnum.TYPE_PARENT
        }

    }

    data class TestChildItem(override val name: String = "测试") : TestItemType {

        override fun getTestItemType(): TestItemEnum {
            return TestItemEnum.TYPE_CHILD
        }

    }
}

enum class TestItemEnum {
    TYPE_PARENT, TYPE_CHILD
}

interface TestItemType {
    val name: String
    fun getTestItemType(): TestItemEnum
}